package com.diandi.ddsb.service.impl;

import com.diandi.ddsb.bean.Role;
import com.diandi.ddsb.bean.Staff;
import com.diandi.ddsb.manager.RoleManager;
import com.diandi.ddsb.manager.StaffManager;
import com.diandi.ddsb.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;


/**
 * 用户业务层接口
 *
 * @author maliming
 */

@RestController
public class StaffServiceImpl implements StaffService {

    @Autowired
    private StaffManager staffManager;

    @Autowired
    private RoleManager roleManager;

    /**
     * 用户根据id查询接口
     *
     * @return
     * @author maliming
     */
    @Override
    public Staff findStaff(Long id) {
        Staff staff = staffManager.findStaff(id);
        Role role = roleManager.findParentById(staff.getRoleId());
        staff.setRoleName(role.getRoleName());
        return staff;
    }

    /**
     * 用户根据email查询接口
     *
     * @return
     * @author maliming
     */
    @Override
    public Staff findByNickname(String nickname) {
        return staffManager.findByNickname(nickname);
    }


}
